home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 June / Amiga Games Extra 1996 #6.iso / userbox / publicdomain / quickdir / rexx / diskbuttons-1.dw
Text File  |  1996-03-23  |  6KB  |  263 lines

  1. ›/*
  2. ** DirWorks ARexx Script
  3. **
  4. **
  5. ** This program will create two columns of buttons. One on each side of an
  6. ** overscan/non-interlaced DW-2 screen. Each button will hold a disk drive
  7. ** path or assignment.
  8. */
  9.  
  10. options  results
  11. parse arg config
  12.  
  13. bg.1=3        /* Background color pen for real drives/partitions */
  14. co.1=2        /* Text color pen for real drives/partitions */
  15. bg.2=6        /* Background color pen for assignments */
  16. co.2=2        /* Text color pen for assignments */
  17.  
  18. /* Enter all the subdirectory segments you want skip. */
  19. skip    = 'asim adpro jpeg game bbs doors/ copiers Video: ca:'
  20.  
  21. /* Enter the assignments/drives you want to guarantee to be used */
  22. force    = 'S C ENV T REXX MyC MyNew Work UUCP UUMail UUSpool'
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. /* ------------------< CHANGE NOTHING BEYOND THIS POINT >------------------ */
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. if length(config)<1 then config='s:dw.cfg'
  39.  
  40. say ''
  41. say ''
  42.  
  43. skip=upper(skip)
  44. force=upper(force)
  45.  
  46. count=0
  47. if open(infile,config,'r') then do
  48.     say 'Reading config "'config'"...'
  49.     t=readln(infile)
  50.     do while ~eof(infile)
  51.         if left(t,3)='B,x' then do
  52.             t2=translate(t,' _',', ')
  53.             do x=1 to words(t2)
  54.                 t3=word(t2,x)
  55.                 if left(t3,2)="t'" & right(t3,3)="'@D" & pos(' q$5 ',t2)>0 then t=''
  56.                 if pos('h230',t3) then t=''
  57.             end
  58.         end
  59.         if length(t)>0 then do
  60.             count=count+1
  61.             line.count=t
  62.         end
  63.         t=readln(infile)
  64.     end
  65.     close(infile)
  66.  
  67.     bcount=1
  68.     button.1='RAM'        ; path.1='RAM:'
  69.  
  70.     say 'Adding buttons...'
  71.     shell command 'info >t:dw-buttons.list1'
  72.     shell command 'sort t:dw-buttons.list1 TO t:dw-buttons.list'
  73.     if open(infile,'t:dw-buttons.list','r') then do
  74.         t=readln(infile)
  75.         do while ~eof(infile)
  76.             if words(t)>2 & right(word(t,1),1)=':' & word(t,1)~='RAM:' then do
  77.                 t2=word(t,1)
  78.                 t3=word(t,words(t))||':'
  79.                 bcount=bcount+1
  80.                 button.bcount=t2
  81.                 path.bcount=t2
  82.                 if left(t2,2)='DH' then do
  83.                     button.bcount=strip(left(word(t3,1),7))
  84.                     path.bcount=t3
  85.                 end
  86.             end
  87.             t=readln(infile)
  88.         end
  89.         close(infile)
  90.     end
  91.  
  92.     do x=1 to bcount
  93.         button.x=strip(translate(button.x,' ',':'))
  94.     end
  95.  
  96.     start=bcount+1
  97.  
  98.     used=''
  99.  
  100.     
  101.     shell command 'assign >t:dw-buttons.list1'
  102.     shell command 'sort t:dw-buttons.list1 t:dw-buttons.list'
  103.  
  104.     if open(infile,'t:dw-buttons.list','r') then do
  105.         t=readln(infile)
  106.         do while ~eof(infile)
  107.             p=pos('RAM DISK:',upper(t))
  108.             if p>0 then t=overlay('     RAM:',t,p)
  109.             if word(t,1)~='+' & words(t)=2 & left(word(t,2),1)~='[' then do
  110.                 bcount=bcount+1
  111.                 button.bcount=strip(left(word(t,1),7))
  112.                 path.bcount=word(t,2)
  113.                 used=used' 'upper(word(t,2))
  114.             end
  115.             t=readln(infile)
  116.         end
  117.         close(infile)
  118.     end
  119.     
  120.     shell command 'copy s:dw.cfg to s:dw.old.cfg'
  121.  
  122.  
  123.     if words(skip)>0 then do
  124.         say 'Removing unwanted buttons...'
  125.         x=start
  126.         do while x<=bcount
  127.             y=x-1
  128.             if button.y=button.x then do
  129.                 if length(path.y)<length(path.x) then z=y; else z=x
  130.                 button.z=button.bcount
  131.                 path.z=path.bcount
  132.                 bcount=bcount-1
  133.             end
  134.             SkipIt=0
  135.             z=1
  136.             do while z<=words(skip) & SkipIt=0
  137.                 if pos(word(skip,z),upper(button.x' 'path.x))>0 then do
  138.                     SkipIt=1
  139.                     button.x=button.bcount
  140.                     path.x=path.bcount
  141.                     bcount=bcount-1
  142.                 end
  143.                 z=z+1
  144.             end
  145.             if SkipIt=0 then x=x+1
  146.         end
  147.     end
  148. do qq=1 to bcount; shell command 'echo >>t:test "'qq'...   'button.qq'"'; end
  149. shell command 'echo >>t:test ""'
  150.  
  151.     if bcount>46 then do
  152.         say 'You have 'bcount' buttons...  That is too many...'
  153.         say 'Sorting buttons by path...'
  154.         sorted=0
  155.         do while sorted=0
  156.             sorted=1
  157.             do x=start to  bcount-1
  158.                 y=x+1
  159.                 if upper(path.x)>upper(path.y) then do
  160.                     t=button.x
  161.                     button.x=button.y
  162.                     button.y=t
  163.                     t=path.x
  164.                     path.x=path.y
  165.                     path.y=t
  166.                     sorted=0
  167.                 end
  168.             end
  169.         end
  170.         say 'Stripping any duplicate paths...'
  171.         x=start
  172.         do while x<bcount
  173.             y=x+1
  174.             if upper(path.x) = upper(path.y) then do
  175.                 if pos(upper(button.x),force)<1 | pos(upper(button.y),force)<1 then do
  176.                     if pos(upper(button.y),force)>0 then button.x=button.y
  177.                     do z=y to bcount-1
  178.                         zz=z+1
  179.                         button.z=button.zz
  180.                         path.z=path.zz
  181.                     end
  182.                     bcount=bcount-1
  183.                 end; else x=x+1
  184.             end; else x=x+1
  185.         end
  186.         if bcount>46 then do
  187.             say 'There are now 'bcount' buttons... Still too many...'
  188.             say 'Trunkating the button list...'
  189.             y=start
  190.             z=bcount
  191.             do x=start to bcount
  192.                 do while pos(upper(button.x),upper(force))>0 & y<bcount
  193.                     t=button.x
  194.                     button.x=button.y
  195.                     button.y=t
  196.                     t=path.x
  197.                     path.x=path.y
  198.                     path.y=t
  199.                     y=y+1
  200.                 end
  201.             end
  202.             bcount=46
  203.         end
  204.     end
  205.     
  206.     say 'Sorting buttons by name...'
  207.     sorted=0
  208.     do while sorted=0
  209.         sorted=1
  210.         do x=start to  bcount-1
  211.             y=x+1
  212.             if upper(button.x)>upper(button.y) then do
  213.                 t=button.x
  214.                 button.x=button.y
  215.                 button.y=t
  216.                 t=path.x
  217.                 path.x=path.y
  218.                 path.y=t
  219.                 sorted=0
  220.             end
  221.         end
  222.     end
  223.  
  224.     high=10
  225.     half=23
  226.     if bcount<46 then do
  227.         if bcount/2 ~= trunc(bcount/2) then do
  228.             bcount=bcount+1
  229.             button.bcount=''
  230.             path.bcount='RAM:'
  231.         end
  232.         half=bcount/2
  233.         high=trunc(230/half)
  234.     end
  235.  
  236.     if open(outfile,config,'w') then do
  237.         say 'Writing config...'
  238.         do x=1 to count
  239.             writeln(outfile,line.x)
  240.         end
  241.         xx=0
  242.         yy=11
  243.         do x=1 to bcount
  244.             if x<start then z=1; else z=2
  245.             t="B,x"xx",y"yy",w60,h"high",c"co.z",b"bg.z",l2,d1,L1,D2,f'IBM.font'"
  246.             t=t||",s7,t'"button.x"'@D,q$5,n'"path.x"',v20,m$100002@D,q$11,n'"path.x
  247.             t=t||"',v20,m$100004"
  248.             writeln(outfile,t)
  249.             yy=yy+high
  250.             if x=half then do
  251.                 yy=11
  252.                 xx=659
  253.             end
  254.         end
  255.         close(outfile)
  256.     end
  257.     say 'Done...'
  258.  
  259. end
  260.  
  261. shell command 'delete <>NIL: t:dw-buttons.list#?'
  262. shell command 'run <>NIL: rx "address ''DIRWORK_1''; ''X@X,v1,n'''''config'''''''"'
  263.